﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using DataAccessClasses;

namespace eschoolBO
{
    public class polloption
    {
        iDAC DAC = DACFactory.GetDAC();
        private long _option_id = -99;
        private long _poll_id = -99;
        private string _answer = "";
        private long _vote = -99;
        private bool _isdeleted = false;
        public long option_id
        {
            set { _option_id = value; }
            get { return _option_id; }
        }
        public long poll_id
        {
            set { _poll_id = value; }
            get { return _poll_id; }
        }
        public string answer
        {
            set { _answer = value; }
            get { return _answer; }
        }
        public long vote
        {
            set { _vote = value; }
            get { return _vote; }
        }
        public bool isdeleted
        {
            set { _isdeleted = value; }
            get { return _isdeleted; }
        }
        public long SaveRecords()
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@option_id", option_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@poll_id", poll_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@answer", answer, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@vote", vote, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3,dbparam4};
                return DAC.Save("polloption_save", dbparamcall);
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return -99;
        }
        public DataTable GetRecords(long option_id,long poll_id, string answer, long vote, bool isdeleted, string paraandor)
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@option_id", option_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@poll_id", poll_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@answer", answer, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@vote", vote, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam5 = DAC.Parameter("@paraandor", paraandor, DbType.AnsiString, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4,dbparam5 };
                DataTable dt = DAC.Select("polloption_get", dbparamcall);
                return dt;
            }
            catch(Exception ex)
            {
                long Result =-99;
            }
            return null;
        }
    }
}
